function findContentChildren(g: number[], s: number[]): number {
    g.sort((a, b) => a - b);
    s.sort((a, b) => a - b);
    let gIndex: number = 0;
    for (let index = 0; gIndex < g.length && index < s.length; index++) {
        s[index] > g[gIndex] && gIndex++
    }
    return gIndex
};

function findContentChildren2(g: number[], s: number[]): number {
    g.sort((a, b) => a - b);
    s.sort((a, b) => a - b);
    return s.reduce((gIndex, sItem) => sItem >= g[gIndex] ? gIndex + 1 : gIndex, 0)
};